package com.ushine.web.component.task.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ushine.web.component.page.PageRequestQuery;
import com.ushine.web.component.task.mapper.AsyncTaskInfoMapper;
import com.ushine.web.component.task.model.AsyncTaskInfoDO;
import com.ushine.web.component.task.service.IAsyncTaskService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: yls
 * @Date: 2022/02/21 12:03
 * @Description: 异步任务service
 * @Version 1.0
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AsyncTaskServiceImpl extends ServiceImpl<AsyncTaskInfoMapper, AsyncTaskInfoDO>
        implements IAsyncTaskService {
    @Override
    public Boolean insertAsyncTask(AsyncTaskInfoDO asyncTaskInfoDO) {
        return save(asyncTaskInfoDO);
    }

    @Override
    public Boolean updateAsyncTask(AsyncTaskInfoDO asyncTaskInfoDO) {
        return updateById(asyncTaskInfoDO);
    }

    @Override
    public Page<AsyncTaskInfoDO> listAsyncTaskInfos(PageRequestQuery pageRequestQuery) {
        Page<AsyncTaskInfoDO> page = new Page<>(pageRequestQuery.getPageNum(), pageRequestQuery.getPageSize());
        LambdaQueryWrapper<AsyncTaskInfoDO> queryWrapper = new LambdaQueryWrapper<>();
        return page(page, queryWrapper);
    }

    @Override
    public AsyncTaskInfoDO getAsyncTaskInfoById(Long id) {
        return getById(id);
    }
}
